#pragma once
#include "Stdafx.h"
#include "Vector2D.h"
#include "Sprite.h"
#include "Vector3D.h"

namespace Pulpy {
	
	static Vector2D<float> _GRAVITY2D_(0,9.81f);
	class Object2D
	{
	private:
		float _Width;
		float _Height;
		float _Radius;
		bool _Solid;
		bool AnimationInvert;
		Vector2D<float> _Position;
	public:
		Object2D():_Width(0),_Height(0),_Radius(0),_Solid(true) { }
		//Width and heights determines the square to square container. Radius defines Circle to circle.
		//Recommended to set Radius and width as same. Unless Collision treatment difference.
		Object2D(float w, float h, float r = 0, bool s = true):_Width(w),_Height(h),_Radius(r),_Solid(s) { }
		~Object2D() { _Width = 0; _Height = 0; _Radius = 0; }

		void setWidth(float w) { _Width = w; }
		float getWidth() { return _Width; }
		void setHeight(float h) { _Height = h; }
		float getHeight() { return _Height; }
		void setRadius(float r) { _Radius = r; }
		float getRadius() { return _Radius; }
		float getTop() { return _Position.getY() - _Height / 2; }
		float getBottom() { return _Position.getY() + _Height / 2; }
		float getLeft() { return _Position.getX() - _Width / 2; }
		float getRight() { return _Position.getX() + _Width / 2; }
		void setSolid(bool s) { _Solid = s; }
		bool getSolid() { return _Solid; }
		bool Contain(Object2D &ob);
		bool Contain(float x, float y){ return Contain(Vector2D<float>(x,y)); };
		bool Contain(Vector2D<float> &v);
		bool Intersects(Object2D &ob);
		void faceLeft() { AnimationInvert = false; }
		void faceRight() { AnimationInvert = true; }
		void setPosition(const Vector2D<float> &v) { _Position = v; }
		void setPosition(float x, float y) { _Position = Vector2D<float>(x, y); }
		void move(float x, float y) { _Position += Vector2D<float>(x, y); }
		void move(const Vector2D<float> &v) { _Position += v; }
		void drawPlane(GLuint texture = 0);
		void drawPlane(Sprite * sprite, int index);
		void drawCircle();
		Vector2D<float> getPosition() { return _Position; }
	};
}